package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.domain.Address;
import com.itheima.entity.Result;
import com.itheima.service.AddressService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/mobile/address")
@RestController
public class MobileAddressController {

    @Reference
    private AddressService addressService;

    @RequestMapping("/findAll")
    public Result findAll(){

        Result result = null;

        try{

            List<Address> list = addressService.findAll();

            result = new Result(true , MessageConstant.ADD_ADDRESS_SUCCESS , list);


        }catch (Exception ex){

            ex.printStackTrace();

            result = new Result(false , MessageConstant.QUERY_ADDRESS_FAIL);



        }

        return  result;


    }

}
